﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Interfaces;
using SQLDao;
using FileDao;

namespace MixedDAO
{
    public class MixedDAOFactory : IDAOFactory
    {
        IUserDAO userdao;
        IRoleDAO roledao;
        IHostedFileDAO hfdao;
        IStorageDAO stordao;

        public MixedDAOFactory(string user_daotype, string role_daotype, string hostfiles_daotype, string storage_daotype)
        {
            var sql_factory = new SQL_DAO_Factory();
            var file_factory = new FileDAOFactory();

            switch (user_daotype)
            {
                case "SQL":
                default:
                    userdao = sql_factory.GetUserDAO();
                    break;
            }

            switch (role_daotype)
            {
                case "SQL":
                default:
                    roledao = sql_factory.GetRoleDAO();
                    break;
            }
            switch (hostfiles_daotype)
            {
                case "SQL":
                default:
                    hfdao = sql_factory.GetHostedFileDAO();
                    break;
            }
            switch (storage_daotype)
            {
                case "FILE":
                default:
                    stordao = file_factory.GetStorageDAO();
                    break;
            }
        }

        public IUserDAO GetUserDAO()
        {
            return userdao;
        }

        public IRoleDAO GetRoleDAO()
        {
            return roledao;
        }

        public IHostedFileDAO GetHostedFileDAO()
        {
            return hfdao;
        }

        public IStorageDAO GetStorageDAO()
        {
            return stordao;
        }
    }
}
